package org.wendu.wdoa.dao;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;
import org.wendu.wdoa.dto.RoleQueryDto;
import org.wendu.wdoa.model.Fun;
import org.wendu.wdoa.model.Role;

import java.util.List;

public interface RoleDao {


    List<Fun> findRoleFunList(Integer roleId);

    List<Role> findRoleList(RoleQueryDto dto);

    @Delete("delete from t_rf where ro_id = #{ro_id}")
    void deleteFunsByRoleId(Integer ro_id);


    @Delete("delete from t_role where ro_id = #{ro_id}")
    void deleteUserByRoleId(Integer ro_id);


    void insertRoleFuns(@Param("roleId") Integer ro_id,
                        @Param("funIds") Integer[] funIds);

    @Insert("insert t_role set ro_id=#{roId},ro_name=#{roName}")
    void insertUser(Integer roId, String roName);

    @Update("update t_role set ro_name=#{ro_name} where ro_id=#{ro_id};")
    void changeUser(Integer ro_id, String ro_name);
}
